<?php

namespace
{

  spl_autoload_register("bee_autoload");

  /**
   * Includa odgovarajuću datoteku klase
   * @param $class_name
   */
  function bee_autoload($class_name)
  {
    static $set = false;
    if(!$set)
    {
      set_include_path(get_include_path()     . PATH_SEPARATOR . bee\config::LIBRARY_PATH
      . PATH_SEPARATOR . bee\config::CONFIG_PATH
      . PATH_SEPARATOR . bee\config::LIBRARY_PATH . "/interface"
      . PATH_SEPARATOR . bee\config::LIBRARY_PATH . "/trait");
        $set = true;
        //echo get_include_path();
    }
    try
    {
      //echo " ** " . $class_name . " ** ";
      $class_name = str_replace("bee\\", "", $class_name);
      if(require_once $class_name . ".php")
      {
        return;
      }
    } catch (Exception $e)
    {
      throw new bee\exception("Class $class_name not found. " . $e->getMessage() . " in path: " . get_include_path(), 6969);
      return;
    }
  }
}

namespace bee
{
  class ClassNotFoundException extends \exception
  {

  }
}